#include "VertexFormats.fx"

struct VSOut
{
	float4 pos : POSITION;
	float2 uv : TEXCOORD0;
	float4 color : COLOR;
};

texture tex : PATTERN_TEXTURE;

sampler tex_sampler = 
sampler_state
{
	Texture = <tex>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
};

VSOut VS_PatternVectorBatch(VertexPosColor input)
{
	VSOut output;
	output.pos = float4(input.pos, 1.0f);
	output.uv = input.pos.xy + float2(1, 1);
	output.uv *= 0.5;
	output.color = input.color;
	return output;
}

float4 PS_PatternVectorBatch(VSOut input) : COLOR
{
    return tex2D(tex_sampler, input.uv) * input.color;
}

technique t0
{
	pass p0
	{
		VertexShader = compile vs_2_0 VS_PatternVectorBatch();
		PixelShader = compile ps_2_0 PS_PatternVectorBatch();
		
		AlphaBlendEnable = true;
		SrcBlend = srcAlpha;
		DestBlend = invSrcAlpha;
		ZEnable = false;
	}
}
